<template>
    <div>
        <pro-table :url="url" :columns="columns">
            <template slot="image" slot-scope="scoped">
                <el-image :src="scoped.row.goods_image"/>
            </template>
            <template slot="do_act" slot-scope="scoped">
                <el-button type="success" size="mini">查看</el-button>
            </template>
            <template slot="price" slot-scope="scoped">
                ￥{{ scoped.row.price }}
            </template>
        </pro-table>
    </div>
</template>
<script>
import ProTable from "@/components/curd/index.vue";
export default {
    components: {
        ProTable
    },
    data() {
        return {
            city: [],
            url: "/api/goods",
            //定义表的列内容展示功能梳理
            columns: [
                {
                    title: "ID",
                    key: "id",
                    placeholder: "请输入ID",
                    // showSearch: false,//是否在搜索框中显示，默认显示,不传传递为true的话，显示在搜索框中
                    // showTable: true, //表格中是否显示，默认显示，不传传递为true的话，显示在表格中
                    // showForm: false,//添加或者编辑的表单是否显示，默认显示不传传递为true的话，显示在表单（添加和编辑)中
                    // isSlot:true,// 插槽是否显示，默认不显示，如果显示请指定slot_name插槽名字  
                }, 
                {
                    title: "商品名称",
                    key: "goods_name",
                    type: "input",
                    placeholder: "请输入商品名字",
                    // showSearch:false,
                    // showForm: false,
                },{
                    title: "商品分类",
                    key: "type",
                    type: "tree",
                    placeholder: "请输入商品分类",
                    showForm: false,
                    showTable: false,
                    values: [
                        {
                            label: '手机',
                            value: 1,
                            children: [
                                { label: '老年机', value: 2 },
                                { label: '智能机', value: 3 },
                                {
                                    label: '苹果手机', value: 4,
                                    children: [
                                        { label: 'iphone11', value: 6 },
                                        { label: 'iphone12', value: 7 },
                                        { label: 'iphone13', value: 8 },
                                        { label: 'iphone14', value: 9 },
                                    ]
                                },
                                { label: '商务机', value: 5 }
                            ]
                        }
                    ],
                },
                {
                    title: "商品状态",
                    key: "status",
                    type: "select",
                    placeholder: "请输入状态",
                    showForm: false,
                    showTable: false,
                    values: [
                        {
                            label: '上架',
                            value: 1,
                        },{
                            label: '下架',
                            value: 2,
                        },{
                            label: '出库',
                            value: 3,
                        },{
                            label: '删除',
                            value: 4,
                        }
                    ],
                },
                {
                    title: "图片",
                    key: "goods_image",
                    type: "upload",
                    placeholder: "请输入内容",
                    // showForm: false,
                    showSearch:false,
                    isSlot: true,
                    slot_name:"image"
                },
                {
                    title: "价格",
                    key: "price",
                    type: "input",
                    placeholder: "请输入商品价格",
                    // showForm: false,
                    isSlot:true,
                    slot_name:"price"
                },
                {
                    title: "重量",
                    key: "weight",
                    type: "input",
                    placeholder: "请输入商品重量",
                    // showForm: false,
                },
                {
                    title: "时间",
                    key: "createTime",
                    type: "time",
                    placeholder: "输入日期",
                    // showForm: false,
                },
                {
                    title: "操作",
                    key: "goods_name",
                    type: "action",
                    // showForm: false,
                    isSlot: true,
                    slot_name:"do_act"
                }
            ]
        };
    },
}
</script>
